﻿<!DOCTYPE html>
<html>
<head>
    <title>第三方接口管理</title>
    <script src="/js/header.js"></script>
    <link href="/lib/sumoselect/sumoselect.css" rel="stylesheet" />
    <script type="text/javascript" src="/lib/sumoselect/jquery.sumoselect.js"></script>
</head>
<body>
    <div class="data-wrap case" id="container">
        <div class="data-tool clearfix">
            <div class="pull-left form-inline ">
                <a class="btn btn-default hide" id="aAdd" data-modal="/view/paymentInterface/edit.html" data-title="新增" data-width="452" data-height="700"><span class="glyphicon glyphicon-plus"></span> 新增</a>
            </div>
            <div class="pull-right">
                <form class="form-inline" id="formSearch" onsubmit="return false;">
                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l gettext">公司名称：</label>
                        <select multiple="multiple" class="search-box-sel-all" name="searchCompanyIds" style="height: 31px;padding: 3px 12px;width:150px;"></select>
                    </div>


                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">接口类型：</label>
                        <select class="form-control" name="paymentType"></select>
                    </div>
                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">状态：</label>
                        <select class="form-control" name="LimitStatus">
                            <option value="0">请选择</option>
                            <option value="1">启用</option>
                            <option value="2">禁用</option>
                        </select>
                    </div>
                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">每天执行：</label>
                        <select class="form-control" name="LimitRepeat">
                            <option value="0">请选择</option>
                            <option value="1">启用</option>
                            <option value="2">禁用</option>
                        </select>
                    </div>
                    <button type="button" class="btn btn-default btn-sm active" id="btnSearch"><span class="glyphicon glyphicon-search"></span> 搜索</button>
                </form>
            </div>
        </div>
        <div class="paging">
        </div>

    </div>
    <script type="text/x-dot-template" id="templatePager">
        <div class="data-body data-scroll">
            <div class="data-view">
                <div class="data-div-view table-responsive">
                    <table class="table table-hover table-striped table-bordered">
                        <thead>
                            <tr>
                                <th class="t_l">公司名称</th>
                                <th class="t_l wd130">余额</th>
                                <th class="t_l wd100">接口类型</th>
                                <th class="t_l wd150">商户名称(号)</th>
                                <th class="wd150 t_r">付款区间起迄</th>
                                <th class="wd150 t_l">客户收款银行</th>
                                <th class="t_l wd125">存款等级</th>
                                <th class="t_r wd100">订单提交笔数</th>
                                <th class="t_l wd100">每天执行</th>
                                <th class="wd75 t_l">开起时间</th>
                                <th class="wd75 t_l">关闭时间</th>
                                <th class="wd75 t_l">排序</th>
                                <th class="t_l wd75">状态</th>
                                <th class="wd175">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            {{? it.tData && it.tData.length>0}}
                            {{~it.tData :item:index}}
                            <tr>
                                <td class="t_l" title="{{= item.company.companyNameEn }}">{{= item.company.companyName }}</td>
                                <td class="t_r" title="{{= item.company.companyNameEn }}">
                                    {{? item.enableBalanceCheck==1 && item.balancePermission=='PaymentInterface0006'}}
                                    <button type="button" class="btn btn-default btn-xs" onclick="return view(this)" data-href="/view/paymentInterface/paymentinterfacebalance.html?id={{= item.paymentInterfaceID}}" data-title="余额设置 - {{= item.company.companyName }}" data-width="800" data-height="470"> 设置</button>
                                    {{?}}

                                    {{= item.balance }}
                                </td>
                                <td class="t_l">
                                    {{= item.paymentTypeName==null?"":item.paymentTypeName }}
                                </td>
                                <td class="t_l" title="{{= item.companyName==null?"":item.companyName }}">
                                    {{= item.companyName==null?"":item.companyName }}
                                </td>
                                <td class="t_r">{{= item.paymentStart }} - {{= item.paymentEnd }}</td>
                                <td class="t_l" data-toggle="tooltip" title="{{= item.withdrawalBank }}">{{= FlashPay.Util.SplitFirstValue(item.withdrawalBank) }}</td>
                                <td class="t_l">{{= item.depositType }}</td>
                                <td class="t_r">{{= item.paymentMax}}</td>
                                <td class="t_l">{{= FlashPay.Util.GetStatusValue(item.limitRepeat) }}</td>
                                <td class="t_l">{{= FlashPay.Util.GetDateByTime(item.limitOpenDate,1) }}</td>
                                <td class="t_l">{{= FlashPay.Util.GetDateByTime(item.limitCloseDate,1) }}</td>
                                <td class="t_l">{{= item.sortNo>0?item.sortNo:"" }}</td>
                                <td class="t_l">{{= FlashPay.Util.GetStatusValue(item.limitStatus) }}</td>
                                <td class="">

                                    {{? item.limitStatus>1 && it.permission.canEdit}}
                                    <button type="button" class="btn btn-default btn-xs" data-modal="/view/paymentInterface/edit.html?id={{= item.paymentInterfaceID}}" data-title="编辑 - {{= item.company.companyName }}" data-width="452" data-height="700">
                                        <span class="glyphicon glyphicon-edit"></span> 编辑
                                    </button>
                                    {{?}}

                                    {{? it.permission.canDisable}}
                                    {{? item.limitStatus==1}}
                                    <a class="btn btn-warning btn-xs"
                                       data-confirm='"{{= item.company.companyName }}" <br>确定要执行<span class="orange">禁用</span>操作吗？'
                                       data-href="/SysConfig/UpdateStatus?CompanyID={{= item.companyID}}&Type=0&LimitStatus=2&PaymentType={{=item.paymentType}}">禁用</a>
                                    {{?? item.limitStatus==2}}
                                    <a class="btn btn-success btn-xs"
                                       data-confirm='"{{= item.company.companyName }}" <br>确定要执行<span class="green">启用</span>操作吗？'
                                       data-href="/SysConfig/UpdateStatus?CompanyID={{= item.companyID}}&Type=0&LimitStatus=1&PaymentType={{=item.paymentType}}">启用</a>
                                    {{?}}
                                    {{?}}

                                    {{? item.limitStatus==2 && it.permission.canDelete}}
                                    <a class="btn btn-danger btn-xs"
                                       data-confirm='"{{= item.company.companyName }}" <br>确定要<span class="red">删除</span>吗？'
                                       data-href="/SysConfig/DeleteInterface?CompanyID={{= item.companyID}}&Type=1&PaymentType={{=item.paymentType}}">
                                        <span class="glyphicon glyphicon-trash"></span>&nbsp;刪除
                                    </a>
                                    {{?}}
                                </td>
                            </tr>
                            {{~}}
                            {{??}}
                            <tr class="noRecord">
                                <td colspan="14">暂无记录！</td>
                            </tr>
                            {{?}}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!-- 必要的分页参数设置 -->
        <input type="hidden" id="TotalCount" value="{{=it.totalCount}}" />
    </script>
    <script type="text/javascript">
    var paymentType = $("select[name='paymentType']");    var searchCompanyIds = $("select[name='searchCompanyIds']");    $(function () {
        FlashPay.UI.DataAutoHeight();

        FlashPay.Util.Ajax({
            type: "POST",
            url: "/SysConfig/CheckAddPermission",
            dataType: "json",
            contentType: "application/json",
            success: function (res) {
                if (res.success) {
                    $("#aAdd").removeClass("hide");
                } else {
                    $("#aAdd").remove();
                }
            }
        });

        doSearch();

        $("#btnSearch").click(function () {
            doSearch();
        });

        FlashPay.Util.Ajax({
            type: "POST",
            url: "/payment/GetSysConfig",
            dataType: "json",
            contentType: "application/json",
            success: function (res) {
                if (res.success) {
                    if (res.data != null) {
                        var selectText = $.i18n.singleReplace("请选择")

                        paymentType.append("<option value=''>" + selectText + "</option>");
                            
                        $.each(res.data, function (i, item) {
                            var text = $.i18n.singleReplace(item.configContent)
                            if (!FlashPay.Util.isNullOrEmptySpance(text)) {
                                paymentType.append("<option value='" + item.configValue + "'>" + text + "</option >");
                            } else {
                                paymentType.append("<option value='" + item.configValue + "'>" + item.configContent + "</option >");
                            }
                        });
                    }
                }
            }
        });

        FlashPay.Util.Ajax({
            type: "POST",
            url: "/Role/GetCompany",
            data: null,
            success: function (response) {
                if (response.success) {

                    searchCompanyIds.empty();
                    if (response.data != null) {
                        $.each(response.data, function (i, item) {
                            searchCompanyIds.append("<option value='" + item.companyID + "'>" + item.companyName + "</option >");
                        });
                        searchCompanyIds.SumoSelect({ okCancelInMulti: true, selectAll: true });
                    }
                    //cover.Remove();
                } else {
                    //cover.Remove();
                }
            },
            error: function (e) {
                cover.Remove();
                FlashPay.UI.Tip_short_warning("操作失败！请查看网络，请重试");
            }
        });    });

    $(document).keyup(function (event) {
        var keycode = event.which;
        if (keycode == 13) {
            FlashPay.UI.DoSearch();
        }
    });

    function doSearch() {
        FlashPay.UI.Pager(".paging", { templateId: "templatePager", pageSize: 15, ajax: { url: '/SysConfig/GetPayMentInterfaceList' } });
    }

    function Tip_success(word) {
        FlashPay.UI.Tip_success(word);
    }

    function view(obj) {
        eval(function (p, a, c, k, e, r) { e = String; if (!''.replace(/^/, String)) { while (c--) r[c] = k[c] || c; k = [function (e) { return r[e] }]; e = function () { return '\\w+' }; c = 1 }; while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); return p }('5.6.7($(0).1("8"),{2:$(0).1("2"),3:$(0).1("3"),4:$(0).1("4")});', 9, 9, 'obj|data|title|width|height|FlashPay|UI|DialogOpen|href'.split('|'), 0, {}))
    }
    </script>
</body>
</html>